﻿package com.mui.controls
{
    import com.mui.core.*;
    import com.mui.events.*;
    import flash.display.*;
    import flash.filters.*;
    import flash.geom.*;
    import flash.text.*;

    public class GLoadedButton extends GButton
    {
        private var _my9Gride:Rectangle;
        protected var _resName:String;
        protected var _isHasInitStyle:Boolean = false;
        public static const diableTextFormat:TextFormat = new TextFormat(null, 12, 8158332);
        private static var _getPath:Function;
        private static const colorFilter2:ColorMatrixFilter = new ColorMatrixFilter([0.5086, 0.2094, 0.082, 0, 0, 0.5086, 0.2094, 0.082, 0, 0, 0.5086, 0.2094, 0.082, 0, 0, 0, 0, 0, 1, 0]);

        public function GLoadedButton()
        {
            this.buttonMode = true;
            this.useHandCursor = true;
            this.tabChildren = false;
            setStyle("overSkin", new Bitmap());
            setStyle("upSkin", new Bitmap());
            setStyle("downSkin", new Bitmap());
            setStyle("disabledSkin", new Bitmap());
            setStyle("disabledTextFormat", diableTextFormat);
            return;
        }// end function

        public function get my9Gride() : Rectangle
        {
            return this._my9Gride;
        }// end function

        public function set my9Gride(param1:Rectangle) : void
        {
            this._my9Gride = param1;
            return;
        }// end function

        protected function getPath() : String
        {
            if (_getPath == null)
            {
                return this._resName;
            }
            return _getPath.call(null, this._resName);
        }// end function

        override public function get styleName() : String
        {
            return this._resName + "_upSkin";
        }// end function

        override public function set styleName(param1:String) : void
        {
            if (!param1)
            {
                return;
            }
            this._resName = param1.replace("_upSkin", "");
            this.setStyles();
            return;
        }// end function

        protected function setStyles() : void
        {
            if (!GlobalClass.hasRes(this._resName + "_upSkin"))
            {
                return;
            }
            setStyle("overSkin", this.getBimap("_overSkin"));
            setStyle("upSkin", this.getBimap("_upSkin"));
            setStyle("downSkin", this.getBimap("_downSkin"));
            setStyle("disabledSkin", this.getBimap("_disabledSkin"));
            this._isHasInitStyle = true;
            this.dispatchEvent(new MuiEvent(MuiEvent.GLOADEDBUTTON_STYLE_COMPLETE));
            return;
        }// end function

        public function get isHasInitStyle() : Boolean
        {
            return this._isHasInitStyle;
        }// end function

        protected function getBimap(param1:String) : Bitmap
        {
            var _loc_2:* = this._resName + param1;
            if (GlobalClass.hasRes(_loc_2))
            {
                if (this._my9Gride != null)
                {
                    return GlobalClass.getScaleBitmap(_loc_2, this._my9Gride);
                }
                return GlobalClass.getBitmap(_loc_2);
            }
            else
            {
                if (this._my9Gride != null)
                {
                    return GlobalClass.getScaleBitmap(this._resName + "_upSkin", this._my9Gride);
                }
            }
            return GlobalClass.getBitmap(this._resName + "_upSkin");
        }// end function

        public function set filterEnabled(param1:Boolean) : void
        {
            this.enabled = param1;
            this.filters = param1 ? (null) : ([colorFilter2]);
            return;
        }// end function

        override public function dispose(param1:Boolean = true) : void
        {
            super.dispose(param1);
            this._my9Gride = null;
            this._isHasInitStyle = false;
            this._resName = "";
            setStyle("overSkin", new Bitmap());
            setStyle("upSkin", new Bitmap());
            setStyle("downSkin", new Bitmap());
            setStyle("disabledSkin", new Bitmap());
            setStyle("disabledTextFormat", diableTextFormat);
            return;
        }// end function

        public static function setGetPath(param1:Function) : void
        {
            _getPath = param1;
            return;
        }// end function

    }
}
